#include "precompiled.h"
#include "meleedps.h"
using namespace std;
using namespace weo::engine::item;
using namespace weo::engine::character;
bool filterItemMelee(const weo::engine::item::Item* item)
{
    std::vector<weo::engine::item::Attribute>::const_iterator k;
    const std::vector<Attribute> *attrs = item->Attributes();
    bool badattr = false;
    for(k = attrs->begin();k!=attrs->end();k++)
    {
        switch(k->Type())
        {
        case 20:
            badattr = true;
            break;
        default:
            break;
        }
    }
    return badattr;
}
void Meleedps::filterEquip(std::vector<std::vector<const weo::engine::item::Item*>>& items)
{
    std::vector<std::vector<const weo::engine::item::Item*>>::iterator i;
    for(i = items.begin();i!= items.end();i++)
    {
        i->erase(std::remove_if(i->begin(), i->end(), filterItemMelee),i->end());
    }
    Character::filterEquip(items);
}
void Meleedps::handleAttribute(const Attribute& attr)
{
    switch(attr.Type())
    {
    default:
        Character::handleAttribute(attr);
        break;
    }
}
void Meleedps::evaluteItem(const weo::engine::item::Item& item, const unsigned int slot)
{
    Character::evaluteItem(item,slot);
    if(item.Type() == 4)
    {
        switch(slot)
        {
        case 14:
            {
                m_Equip[weo::engine::item::Attribute::getAttributeValue("MainhandDps")] = item.DPS();
                m_Equip[weo::engine::item::Attribute::getAttributeValue("MainhandSpeed")] = item.Speed();
                break;
            }
        case 15:
            {
                m_Equip[weo::engine::item::Attribute::getAttributeValue("OffhandDps")] = item.DPS();
                m_Equip[weo::engine::item::Attribute::getAttributeValue("OffhandSpeed")] = item.Speed();
                break;
            }
        default:
            break;
        }
    }
}
void Meleedps::Init()
{
    m_AttributesVector.push_back("MainhandDps");
    m_AttributesVector.push_back("MainhandSpeed");
    m_AttributesVector.push_back("OffhandDps");
    m_AttributesVector.push_back("OffhandSpeed");
    m_AttributesVector.push_back("CritRating");
    m_AttributesVector.push_back("HitRating");
    m_AttributesVector.push_back("AttackPower");
    m_AttributesVector.push_back("HasteRating");
    m_AttributesVector.push_back("Health");

    Character::Init();

    m_Buffs["Blessing of Might"].Active(true);
    m_Buffs["Flask of Relentless Assault"].Active(true);
    m_Buffs["Battleshout"].Active(true);
    m_Buffs["Leader of the pack"].Active(true);
    m_Buffs["Roasted Clefthoof"].Active(true);
    m_Buffs["Strength of Earth"].Active(true);
    m_Buffs["Windfury Totem"].Active(true);
}